﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>

<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

  <%@ include file="/WEB-INF/include/meta.jsp"%>
  <%@ include file="/WEB-INF/include/css.jsp"%>
  
</head>

<body>

  <%@ include file="/WEB-INF/include/header.jsp"%>
  <%@ include file="/WEB-INF/include/menu.jsp"%>
  
  <div class="container main-content">
  
    <div class="panel panel-default x-panel x-panel-layout">
  
      <div class="panel-heading">
        <ol class="breadcrumb">
          <li><a href="${ctx.host}/ecommerce">电商管理</a></li>
          <li class="active">订单管理</li>
        </ol>
      </div>
      
      <div class="panel-body">
      
        <div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
          <%@ include file="/WEB-INF/include/submenu.jsp"%>
        </div>
        
        <div class="col-xs-10 x-panel-layout-right">
          
          <div class="x-breadcrumb-wrapper">
            <div class="x-breadcrumb clearfix">
              <h2><i class="glyphicon glyphicon-fire"></i>&nbsp;&nbsp;<span>订单管理&nbsp;-&nbsp;订单详情</span></h2>
            </div>
          </div>
          
          <div class="x-breadcrumb-wrapper top-margin-20">
          
            <!-- tabs -->
            <ul class="nav nav-pills x-breadcrumb-nav ajax-tab" data-content="#order-content" data-operation="#order-operations">
              <li class="pull-left active">
                <a id="orderProfile" href="${ctx.host}/${param.type}-orders/${order.id}/profile/view" data-toggle="tab" data-target="#order-profile">基本信息</a>
              </li>
              <li class="pull-left">
                <a id="orderActivity" href="${ctx.host}/${param.type}-orders/${order.id}/product?view=true" data-toggle="tab" data-target="#order-activity">产品信息</a>
              </li>
            </ul>
            
            <div id="order-operations" class="tab-operation pull-right">
              <div id="orderProfile-operation" class="tab-operations hide">
                <c:if test="${currentPrincipal.root or currentPrincipal.admin or currentPrincipal.areaManager or currentPrincipal.areaServer or currentPrincipal.siteManager or currentPrincipal.siteServer}">
                  <a href="${ctx.host}/${param.type}-orders/${order.id }/edit-user-name" data-target="#edit" data-toggle="modal" title="修改用户姓名">修改用户姓名</a>
                  <a href="${ctx.host}/${param.type}-orders/${order.id }/edit-mobile" data-target="#edit" data-toggle="modal" title="修改手机号/邮箱">修改手机号/邮箱</a>
                </c:if>
                <c:if test="${(currentPrincipal.root or currentPrincipal.admin or 
                		       currentPrincipal.areaManager or currentPrincipal.areaServer or 
                		       currentPrincipal.siteManager or currentPrincipal.onlineCoach or 
                		       currentPrincipal.siteServer) and 
                		       (order.orderType.online or order.orderType.individual or order.orderType.special or order.orderType.posture or order.orderType.year or order.orderType.group)}">
                  <c:if test="${order.paymentStatus.isUnpaid() or (order.orderType.individual and order.course.experience and order.orderStatus == 'PENDING')}">
                    <a href="${ctx.host}/${param.type}-orders/${order.id }/price?priceType=sale" data-target="#edit" data-toggle="modal" title="修改价格">修改价格</a>
                  </c:if>
                  <%-- <c:if test="${order.orderStatus.couldEditRefundPrice()}">
                    <a href="${ctx.host}/${param.type}-orders/${order.id }/price?priceType=refund" data-target="#edit" data-toggle="modal" title="修改退款价格">修改退款价格</a>
                  </c:if> --%>
                </c:if>
              </div>
            </div>
            
          </div>
          
          <div id="order-content" class="tab-content ajax-tab-content">
          
            <div class="tab-pane fade active in" id="order-profile" style="min-height: 160px;">
              
              <div class="form-horizontal">
              
                <div class="form-horizontal">
              
                <div class="form-group">
                  <label class="col-xs-2 control-label">课程：</label>
                  <div class="col-xs-3">
                    <p class="form-control-static">${order.course.name}</p>
                  </div>
                </div>
                
                <div class="form-group">
                  <label class="col-xs-2 control-label">下单用户：</label>
                  <div class="col-xs-3">
                    <p class="form-control-static">${order.user.name}（${order.user.wechat.code}）<br>
                    ${order.user.mobile}</p>
                  </div>
                  
                  <label class="col-xs-2 control-label">学员：</label>
                  <div class="col-xs-3">
                    <p class="form-control-static">${order.student.name}</p>
                  </div>
                </div>
                
                <div class="form-group">
                  <label class="col-xs-2 control-label">订单金额：</label>
                  <div class="col-xs-3">
                    <p class="form-control-static">${order.price/100}</p>
                  </div>
                  
                  <label class="col-xs-2 control-label">下单时间：</label>
                  <div class="col-xs-3">
                    <p class="form-control-static">${order.createTime}</p>
                  </div>
                </div>
                
                <div class="form-group">
                  <label class="col-xs-2 control-label">支付时间：</label>
                  <div class="col-xs-3">
                    <p class="form-control-static">${order.payTime}</p>
                  </div>
                  
                  <label class="col-xs-2 control-label">支付方式：</label>
                  <div class="col-xs-3">
                    <p class="form-control-static">${order.paymentMethod.description}</p>
                  </div>
                </div>
                
                <div class="form-group">
                  <label class="col-xs-2 control-label">订单状态：</label>
                  <div class="col-xs-3">
                    <p class="form-control-static">${order.orderStatus.description}</p>
                  </div>
                  
                  <label class="col-xs-2 control-label">支付状态：</label>
                  <div class="col-xs-3">
                    <p class="form-control-static">${order.paymentStatus.description}</p>
                  </div>
                </div>
                
                <c:if test="${not empty order.discountCode}">
                  <div class="form-group">
                    <label class="col-xs-2 control-label">折扣券码：</label>
                    <div class="col-xs-3">
                      <p class="form-control-static">${order.discountCode}</p>
                    </div>
                    <label class="col-xs-2 control-label">代言人：</label>
                    <div class="col-xs-3">
                      <p class="form-control-static">${order.agent.name}-${order.agent.mobile}</p>
                    </div>
                  </div>
                </c:if>
                
                <div class="form-group">
                  <label class="col-xs-2 control-label">退款原因：</label>
                  <div class="col-xs-3">
                    <p class="form-control-static">${persist.orderAttribute(order)['refoundRemarks'].value}</p>
                  </div>
                  <label class="col-xs-2 control-label">改价原因：</label>
                  <div class="col-xs-3">
                    <p class="form-control-static">${persist.orderAttribute(order)['priceRemarks'].value}</p>
                  </div>
                </div>
                
                <c:if test="${order.orderType.others}">
                  <div class="form-group">
                    <label class="col-xs-2 control-label">身份证号：</label>
                    <div class="col-xs-3">
                      <p class="form-control-static">${persist.orderAttribute(order)['identificationCard'].value}</p>
                    </div>
                    <label class="col-xs-2 control-label">收货地址：</label>
                    <div class="col-xs-3">
                      <p class="form-control-static">${persist.orderAttribute(order)['shipping_address'].value}</p>
                    </div>
                  </div>
                </c:if>
                  
              </div>
                
              </div>
            
            </div>
            
          </div>
          
          <div class="x-breadcrumb-wrapper" style="margin-top:20px;">
            <div class="x-breadcrumb yellow clearfix">
              <h2>
                <span>支付记录</span>
              </h2>
            </div>
          </div>
            
          <table class="table table-striped table-hover x-table" style="margin-bottom:20px;">
            <thead>
              <tr>
                <th>金额</th>
                <th>支付类型</th>
                <th>支付方式</th>
                <th>时间</th>
              </tr>
            </thead>
            <tbody>
              <c:forEach var="receipt" items="${receipts}">
                <tr>
                  <td><fmt:formatNumber value='${receipt.domesticPrice/100}' minFractionDigits='0' maxFractionDigits='2'></fmt:formatNumber></td>
                  <td>${receipt.type.description}</td>
                  <td>${receipt.generalPaymentMethod}</td>
                  <td><fmt:formatDate value = "${receipt.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                </tr>
              </c:forEach>
              
              <c:if test="${not empty otherReceipt}">
                <tr>
                  <td><fmt:formatNumber value='${otherReceipt.domesticPrice/100}' minFractionDigits='0' maxFractionDigits='2'></fmt:formatNumber></td>
                  <td>尾款</td>
                  <td>${order.paymentMethod.description}</td>
                  <td>${order.payTime}</td>
                </tr>
              </c:if>
              
              <c:if test="${order.paymentStatus eq 'REFUNDED' or order.paymentStatus eq 'SYSTEMREFUNDED'}">
                <tr>
                  <td><fmt:formatNumber value='${order.refundPrice/100}' minFractionDigits='0' maxFractionDigits='2'></fmt:formatNumber></td>
                  <td>退款</td>
                  <td>${order.refundMethod.description}</td>
                  <td>${refundReceipt.createTime}${order.attrs['refund_time'].value}</td>
                </tr>
              </c:if>
            </tbody>
          </table>
          
          <!-- investigation -->
          
          <c:if test="${type == 'online' and status == 'pending' and not empty investigate}">
            
            <div class="x-breadcrumb-wrapper" style="margin-top: 50px;">

              <!-- tabs -->
              <ul class="nav nav-pills x-breadcrumb-nav ajax-tab" data-content="#investigate-content" data-operation="#investigate-operations">
                <c:if test="${investigate.profileInvestigation}">
                  <li class="pull-left">
                    <a id="investigateProfile" href="${ctx.host}/online-orders/${order.id }/investigate?investigateType=profile" data-toggle="tab" data-target="#investigate-profile">个人信息调查</a>
                  </li>
                </c:if>
                <c:if test="${investigate.fitInvestigation}">
                  <li class="pull-left">
                    <a id="investigateFit" href="${ctx.host}/online-orders/${order.id }/investigate?investigateType=fit" data-toggle="tab" data-target="#investigate-fit">身体信息调查</a>
                  </li>
                </c:if>
                <c:if test="${investigate.healthInvestigation}">
                  <li class="pull-left">
                    <a id="investigateHealth" href="${ctx.host}/online-orders/${order.id }/investigate?investigateType=health" data-toggle="tab" data-target="#investigate-health">健康调查</a>
                  </li>
                </c:if>
                <c:if test="${investigate.participateInvestigation}">
                <li class="pull-left">
                  <a id="investigateParticipate" href="${ctx.host}/online-orders/${order.id }/investigate?investigateType=participate" data-toggle="tab" data-target="#investigate-participate">参与度调查</a>
                </li>
                </c:if>
              </ul>
              
            </div>

            <div id="investigate-content" class="tab-content ajax-tab-content">
            </div>

          </c:if>
          
          <!-- investigation -->
          
        </div>
        
      </div>
      
    </div>
    
  </div>

  <%@ include file="/WEB-INF/include/script.jsp"%>
  
  <d:resource root="${ctx.resource}/build" type="script" src="js/page/ecommerce/order/order-view.js">
    <script type="text/javascript">
      require(['page/ecommerce/order/order-view'],function(page){
          page.init();
      })
    </script>
  </d:resource>

</body>

</html>